﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class Front_DealShow : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
      //  if (!IsPostBack)
        {
            string DealID;
            string CityID;
            string ReferUserID;
            if (Request.QueryString["ReferUserID"] != null && Request.QueryString["CityID"] != null)
            {
                ReferUserID = Request.QueryString["ReferUserID"].ToString();
                Session["ReferUserID"] = ReferUserID;
                var sub = new DealesDataContext();
                var getDealID = sub.Select_DealByCityIDNew(Convert.ToInt32(Request.QueryString["CityID"]));
                foreach (var item in getDealID)
                {
                    DealID = item.DealID.ToString();
                    Deal1._DealID = Convert.ToInt32(DealID);
                }

            }
            else
            {
                if (Request.QueryString["DealID"] != null)
                {
                    DealID = Request.QueryString["DealID"].ToString();
                    Deal1._DealID = Convert.ToInt32(DealID);
                }
                else
                {
                    if (Request.QueryString["RecentDealID"] != null)
                    {
                        DealID = Request.QueryString["RecentDealID"].ToString();
                        Session["RecentDealID"] = DealID;
                        Deal1._DealID = Convert.ToInt32(DealID);
                    }
                    else
                    {
                        CityID = "0";
                        if (Request.Cookies["CityID"] == null && System.Configuration.ConfigurationManager.AppSettings["DefaultCityID"] != null)
                        {
                            CityID = System.Configuration.ConfigurationManager.AppSettings["DefaultCityID"];
                        }
                        else if (Request.Cookies["CityID"] != null)
                        {
                            CityID = Request.Cookies["CityID"].Value;
                        }

                        var sub = new DealesDataContext();
                        var getDealID = sub.Select_DealByCityIDNew(Convert.ToInt32(CityID));
                        foreach (var item in getDealID)
                        {
                            DealID = item.DealID.ToString();
                            Deal1._DealID = Convert.ToInt32(DealID);
                        }
                    }
                }
            }
        }
    }

 
}
